﻿Imports Library

Namespace HomeApps

    <Authorize()>
    Public Class ScheduleTaskController
        Inherits System.Web.Mvc.Controller

        Function Index() As ActionResult
            Return View()
        End Function

        Function Create() As ActionResult
            Return View()
        End Function

        <HttpPost()> _
        Function Create(ByVal item As ScheduleTask) As ActionResult
            Try
                item.Create()
                Return RedirectToAction("Index")
            Catch
                Return View()
            End Try
        End Function

        Function Edit(ByVal id As Integer) As ActionResult
            Dim item As ScheduleTask = New ScheduleTask(id)
            If item.Id = 0 Then
                Return HttpNotFound()
            Else
                Return View(item)
            End If
        End Function

        <HttpPost()> _
        Function Edit(ByVal id As Integer, ByVal item As ScheduleTask) As ActionResult
            If item.Id = 0 Then
                Return HttpNotFound()
            Else
                item.Update()
                Return RedirectToAction("Index")
            End If
        End Function

        Function Delete(ByVal id As Integer) As ActionResult
            Dim item As ScheduleTask = New ScheduleTask(id)
            If item.Id = 0 Then
                Return HttpNotFound()
            Else
                item.Delete()
                Return RedirectToAction("Index")
            End If
        End Function

    End Class

End Namespace
